import { BaseModel } from './BaseModel.js';
import { dataFiles } from '../config/database.js';

const defaultTeachers = [
  {
    id: 1,
    name: '曲凤才',
    teacherId: 'T001',
    gender: '男',
    birthDate: '1980-05-15',
    idCard: '110101198005154321',
    phone: '13800138001',
    email: 'qufengcai@school.edu',
    department: '计算机学院',
    title: '副教授',
    major: '人工智能',
    course: '企业级人工智能项目实训',
    status: 'active',
    hireDate: '2015-08-01',
    createdAt: new Date().toISOString(),
    updatedAt: new Date().toISOString()
  },
  {
    id: 2,
    name: '张老师',
    teacherId: 'T002',
    gender: '男',
    birthDate: '1982-03-20',
    idCard: '110101198203205678',
    phone: '13800138002',
    email: 'zhang@school.edu',
    department: '软件学院',
    title: '讲师',
    major: '软件工程',
    course: 'Python程序设计',
    status: 'active',
    hireDate: '2018-03-01',
    createdAt: new Date().toISOString(),
    updatedAt: new Date().toISOString()
  },
  {
    id: 3,
    name: '李老师',
    teacherId: 'T003',
    gender: '女',
    birthDate: '1978-11-08',
    idCard: '110101197811086543',
    phone: '13800138003',
    email: 'li@school.edu',
    department: '计算机学院',
    title: '教授',
    major: '计算机科学',
    course: '数据结构',
    status: 'active',
    hireDate: '2010-09-01',
    createdAt: new Date().toISOString(),
    updatedAt: new Date().toISOString()
  }
];

export class Teacher extends BaseModel {
  constructor() {
    super(dataFiles.teachers, defaultTeachers);
  }

  findByTeacherId(teacherId) {
    return this.findOne({ teacherId });
  }

  findByDepartment(department) {
    const data = this.findAll();
    return data.filter(teacher => teacher.department === department);
  }

  findByName(name) {
    const data = this.findAll();
    return data.filter(teacher => teacher.name.includes(name));
  }
}